
    // 舆情来源分布
    var option_day_forecast = {
        color: ['#2ceb43','#fbec47','#fe212a','#4ab6fe','#9933CC',"#BF3EFF","#4876FF"],
        legend : {
            right: 0
        },
        tooltip : {
            trigger: 'axis',
            axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        grid: {
            top: 20,
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis : [
            {
                type : 'category',
                data : ['网易号', '微信', '财经头条', '腾讯新闻企业', '今日头条', 'UC头条大鱼', '天天快报','搜狐号', '东方资讯', '搜狐新闻'],
                axisTick: {
                    alignWithLabel: true
                },
                axisLine: {
                    lineStyle: {
                        color: '#fff'
                    }
                },
            }
        ],
        yAxis : [
            {
                type : 'value',
                axisLabel: {
                    textStyle: {
                        color: '#fff'
                    }
                },
                // splitLine:{//去除网格线
                //     show:false
                // },
            }
        ],
        series : [
            {
                name:'直接访问',
                type:'bar',
                barWidth: '20%',
                data:[19, 11, 11, 14, 7, 4, 3,6, 7, 5],
                itemStyle: {
                    normal: {
                        barBorderRadius: [4, 4, 4, 4],
                        label: {
                            show: true,
                            textStyle: {
                                color: "#a2e9ff"
                            },
                            position: 'top'
                        },
                        color: function (params) {
                            var colorList = ['#003d64', '#4bb6fc', '#a2e9ff', '#0069ad', '#009bff'];
                            return colorList[params.dataIndex];
                        }
                    }
                }
            }
        ]
    };
var dayDiv = echarts.init(document.getElementById('dayDiv'));
// 渲染页面初始数据
dayDiv.setOption(option_day_forecast);
function setDay(data) {
    option_day_forecast.legend.data=data.legend;
    option_day_forecast.xAxis[0].data=data.xAxis;
    var confArr = [];
    data.data.forEach(function (val,key) {
        var obj = $.extend(true, {}, option_day_forecast.series[0]);
        obj.name=String(val.name);
        obj.data=val.data;
        confArr.push(obj)
    })
    option_day_forecast.series=confArr;
    var dayDiv = echarts.init(document.getElementById('dayDiv'));
    dayDiv.setOption(option_day_forecast);
}
function daySearch(t1, t2,type) {
    var opt = {
        type: 'get',
        url: '/bigdata/manage/tourist-compare/day-compare',
        data: {},
        callback: function (res) {
            if (res.code == 1) {
                dyw.box.alert(res.msg);
                return false
            }
            setDay(res.result);
            $("#date1").val(res.result.start_time);
            $("#date2").val(res.result.end_time);
        }
    }
    if (t1) {
        opt.data = {
            start_time: t1,
            end_time: t2
        }
    }
    if(type)  opt.data.type=type;
    loadData(opt)
}
// daySearch();
$("#search1").on('click', function () {
    var t1 = $("#date1").val();
    var t2 = $("#date2").val();
    var type=$("#type1").val()
    if (!t1 || !t2) {
        dyw.box.alert('请选择查询时间');
        return false
    }
    daySearch(t1, t2,type);
})
$("#type1").change(function () {
    $("#search1").click();
})


// 信息来源类型统计
var option_month = {
    color: ['#117982', '#efa247', '#45dde6', '#6b8dc5', '#45afe6'],
    tooltip: {
        trigger: 'item',
        formatter: "{a} <br/>{b}: {c} ({d}%)"
    },
    legend: {
        orient: 'vertical',
        align : "left",
        x: 'right',
        textStyle: {
            color : '#fff',
        },
        data:['客户端','微信','网站','微博','论坛']
    },
    series: [
        {
            name:'数据来源',
            type:'pie',
            radius: ['50%', '70%'],
            avoidLabelOverlap: true,
            labelLine: {
                normal:{  
                    length: 60,
                    length2: 30
                }
            },
            data:[
                {value:69, name:'客户端'},
                {value:8, name:'微信'},
                {value:5, name:'网站'},
                {value:3, name:'微博'},
                {value:2, name:'论坛'}
            ]
        }
    ]
};
// 渲染静态页面
var monthDiv = echarts.init(document.getElementById('monthDiv'));
monthDiv.setOption(option_month);


function setMonth(data) {
    console.log(data.xAxis)
    console.log(data.series)
    option_month.xAxis[0].data=data.xAxis;
    option_month.series[0].data=data.data;
    var monthDiv = echarts.init(document.getElementById('monthDiv'));
    monthDiv.setOption(option_month);
}

function monthSearch(month, type) {
    var opt = {
        type: 'get',
        url: '/bigdata/manage/tourist-compare/month-compare',
        data: {},
        callback: function (res) {
            if (res.code == 1) {
                dyw.box.alert(res.msg);
                return false
            }
            // setMonth(res.result);
            $("#date3").val(res.result.month);
        }
    }
    if (month) {
        opt.data = {
            month: month,
        }
    }
    if (type) opt.data.type = type;
    loadData(opt)
}
// monthSearch();

$("#search2").on('click', function () {
    var t1 = $("#date3").val();
    var type = $("#type2").val()
    if (!t1) {
        dyw.box.alert('请选择查询时间');
        return false
    }
    monthSearch(t1, type);
})
$("#type2").change(function () {
    $("#search2").click()
})


// 年数据
var option_year = {
    color: ['#efa247', '#fbec47', '#fe212a', '#4ab6fe'],
    tooltip: {
        trigger: 'item',
        formatter: "{a} <br/>{b}: {c} ({d}%)"
    },
    legend: {
        orient: 'vertical',
        x: 'right',
        align : 'left',
        textStyle: {
            color : '#fff',
        },
        data:['敏感']
    },
    series: [
        {
            name:'信息分布',
            type:'pie',
            radius: ['50%', '70%'],
            avoidLabelOverlap: false,
            // label: {
            //     normal: {
            //         show: false,
            //         position: 'center'
            //     },
            //     emphasis: {
            //         show: true,
            //         textStyle: {
            //             fontSize: '30',
            //             fontWeight: 'bold'
            //         }
            //     }
            // },
            // labelLine: {
            //     normal: {
            //         show: false
            //     }
            // },
            data:[
                {value:87, name:'敏感'}
            ]
        }
    ]
};

var yearDiv = echarts.init(document.getElementById('yearDiv'));
yearDiv.setOption(option_year);

function setYear(data) {
    option_year.xAxis[0].data = data.xAxis;
    option_year.series[0].name = data.data.name;
    option_year.series[0].data = data.data.value;
    var yearDiv = echarts.init(document.getElementById('yearDiv'));
    yearDiv.setOption(option_year);
}
function yearSearch( type) {
    var opt = {
        type: 'get',
        url: '/bigdata/manage/tourist-compare/year-compare',
        data: {},
        callback: function (res) {
            if (res.code == 1) {
                dyw.box.alert(res.msg);
                return false
            }
            setYear(res.result)
        }
    }
    if (type) opt.data.type = type;
    loadData(opt)
}
// yearSearch();

$("#type3").change(function () {
    var type = $("#type3").val()
    yearSearch(type);
})












